#version 150

uniform vec2 rubyTextureSize;

// incoming vertex position
in vec2 vertex_position;
// incoming vertex texcoord
in vec2 vertex_texcoord;

// transformed texture coordinate
out vec4[8] texcoord;

out vec2 tcc;

void main() 
{
  float dx = 1.0 / rubyTextureSize.x;
  float dy = 1.0 / rubyTextureSize.y;

  //     A1 B1 C1
  //  A0  A  B  C C4
  //  D0  D  E  F F4
  //  G0  G  H  I I4
  //     G5 H5 I5

  
  gl_Position.xy = vertex_position;
  gl_Position.zw = vec2(0.0, 1.0);
  
  tcc = vertex_texcoord;
  texcoord[0].xy = vertex_texcoord.xy;
  texcoord[0].zw = vec2(0.0, 1.0);
  texcoord[1] = vertex_texcoord.xxxy + vec4(    -dx,   0,  dx, -2.0*dy);  //  A1 B1 C1
  texcoord[2] = vertex_texcoord.xxxy + vec4(    -dx,   0,  dx,     -dy);  //   A  B  C
  texcoord[3] = vertex_texcoord.xxxy + vec4(    -dx,   0,  dx,       0);  //   D  E  F
  texcoord[4] = vertex_texcoord.xxxy + vec4(    -dx,   0,  dx,      dy);  //   G  H  I
  texcoord[5] = vertex_texcoord.xxxy + vec4(    -dx,   0,  dx,  2.0*dy);  //  G5 H5 I5
  texcoord[6] = vertex_texcoord.xyyy + vec4(-2.0*dx, -dy,   0,      dy);  //  A0 D0 G0
  texcoord[7] = vertex_texcoord.xyyy + vec4( 2.0*dx, -dy,   0,      dy);  //  C4 F4 I4 
}